<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - id:000977,sync:fuzzer2,src:001052.lcov_info_final - src/exp.cpp</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - exp.cpp<span style="font-size: 80%;"> (source / <a href="exp.cpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">id:000977,sync:fuzzer2,src:001052.lcov_info_final</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">63</td>
            <td class="headerCovTableEntry">63</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2016-03-13 10:42:47</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">6</td>
            <td class="headerCovTableEntry">6</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : #include &lt;sstream&gt;</a>
<span class="lineNum">       2 </span>            : 
<span class="lineNum">       3 </span>            : #include &quot;exp.h&quot;
<span class="lineNum">       4 </span>            : #include &quot;stream.h&quot;
<span class="lineNum">       5 </span>            : #include &quot;yaml-cpp/exceptions.h&quot;  // IWYU pragma: keep
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : namespace YAML {
<span class="lineNum">       8 </span>            : struct Mark;
<span class="lineNum">       9 </span>            : }  // namespace YAML
<span class="lineNum">      10 </span>            : 
<a name="11"><span class="lineNum">      11 </span>            : namespace YAML {</a>
<span class="lineNum">      12 </span>            : namespace Exp {
<span class="lineNum">      13 </span><span class="lineCov">       1198 : unsigned ParseHex(const std::string&amp; str, const Mark&amp; mark) {</span>
<span class="lineNum">      14 </span><span class="lineCov">       1198 :   unsigned value = 0;</span>
<span class="lineNum">      15 </span><span class="lineCov">       4829 :   for (std::size_t i = 0; i &lt; str.size(); i++) {</span>
<span class="lineNum">      16 </span><span class="lineCov">       3656 :     char ch = str[i];</span>
<span class="lineNum">      17 </span><span class="lineCov">       3656 :     int digit = 0;</span>
<span class="lineNum">      18 </span><span class="lineCov">       3656 :     if ('a' &lt;= ch &amp;&amp; ch &lt;= 'f')</span>
<span class="lineNum">      19 </span><span class="lineCov">        696 :       digit = ch - 'a' + 10;</span>
<span class="lineNum">      20 </span><span class="lineCov">       2960 :     else if ('A' &lt;= ch &amp;&amp; ch &lt;= 'F')</span>
<span class="lineNum">      21 </span><span class="lineCov">        751 :       digit = ch - 'A' + 10;</span>
<span class="lineNum">      22 </span><span class="lineCov">       2209 :     else if ('0' &lt;= ch &amp;&amp; ch &lt;= '9')</span>
<span class="lineNum">      23 </span><span class="lineCov">       2184 :       digit = ch - '0';</span>
<span class="lineNum">      24 </span>            :     else
<span class="lineNum">      25 </span><span class="lineCov">         25 :       throw ParserException(mark, ErrorMsg::INVALID_HEX);</span>
<span class="lineNum">      26 </span>            : 
<span class="lineNum">      27 </span><span class="lineCov">       3631 :     value = (value &lt;&lt; 4) + digit;</span>
<span class="lineNum">      28 </span>            :   }
<span class="lineNum">      29 </span>            : 
<span class="lineNum">      30 </span><span class="lineCov">       1173 :   return value;</span>
<a name="31"><span class="lineNum">      31 </span>            : }</a>
<span class="lineNum">      32 </span>            : 
<span class="lineNum">      33 </span><span class="lineCov">       2424 : std::string Str(unsigned ch) { return std::string(1, static_cast&lt;char&gt;(ch)); }</span>
<span class="lineNum">      34 </span>            : 
<span class="lineNum">      35 </span>            : // Escape
<span class="lineNum">      36 </span>            : // . Translates the next 'codeLength' characters into a hex number and returns
<a name="37"><span class="lineNum">      37 </span>            : // the result.</a>
<span class="lineNum">      38 </span>            : // . Throws if it's not actually hex.
<span class="lineNum">      39 </span><span class="lineCov">       1198 : std::string Escape(Stream&amp; in, int codeLength) {</span>
<span class="lineNum">      40 </span>            :   // grab string
<span class="lineNum">      41 </span><span class="lineCov">       2396 :   std::string str;</span>
<span class="lineNum">      42 </span><span class="lineCov">       4970 :   for (int i = 0; i &lt; codeLength; i++)</span>
<span class="lineNum">      43 </span><span class="lineCov">       3772 :     str += in.get();</span>
<span class="lineNum">      44 </span>            : 
<span class="lineNum">      45 </span>            :   // get the value
<span class="lineNum">      46 </span><span class="lineCov">       1223 :   unsigned value = ParseHex(str, in.mark());</span>
<span class="lineNum">      47 </span>            : 
<span class="lineNum">      48 </span>            :   // legal unicode?
<span class="lineNum">      49 </span><span class="lineCov">       1173 :   if ((value &gt;= 0xD800 &amp;&amp; value &lt;= 0xDFFF) || value &gt; 0x10FFFF) {</span>
<span class="lineNum">      50 </span><span class="lineCov">          4 :     std::stringstream msg;</span>
<span class="lineNum">      51 </span><span class="lineCov">          2 :     msg &lt;&lt; ErrorMsg::INVALID_UNICODE &lt;&lt; value;</span>
<span class="lineNum">      52 </span><span class="lineCov">          2 :     throw ParserException(in.mark(), msg.str());</span>
<span class="lineNum">      53 </span>            :   }
<span class="lineNum">      54 </span>            : 
<span class="lineNum">      55 </span>            :   // now break it up into chars
<span class="lineNum">      56 </span><span class="lineCov">       1171 :   if (value &lt;= 0x7F)</span>
<span class="lineNum">      57 </span><span class="lineCov">        390 :     return Str(value);</span>
<span class="lineNum">      58 </span><span class="lineCov">        781 :   else if (value &lt;= 0x7FF)</span>
<span class="lineNum">      59 </span><span class="lineCov">        451 :     return Str(0xC0 + (value &gt;&gt; 6)) + Str(0x80 + (value &amp; 0x3F));</span>
<span class="lineNum">      60 </span><span class="lineCov">        330 :   else if (value &lt;= 0xFFFF)</span>
<span class="lineNum">      61 </span><span class="lineCov">        376 :     return Str(0xE0 + (value &gt;&gt; 12)) + Str(0x80 + ((value &gt;&gt; 6) &amp; 0x3F)) +</span>
<span class="lineNum">      62 </span><span class="lineCov">        564 :            Str(0x80 + (value &amp; 0x3F));</span>
<span class="lineNum">      63 </span>            :   else
<span class="lineNum">      64 </span><span class="lineCov">        284 :     return Str(0xF0 + (value &gt;&gt; 18)) + Str(0x80 + ((value &gt;&gt; 12) &amp; 0x3F)) +</span>
<span class="lineNum">      65 </span><span class="lineCov">        426 :            Str(0x80 + ((value &gt;&gt; 6) &amp; 0x3F)) + Str(0x80 + (value &amp; 0x3F));</span>
<span class="lineNum">      66 </span>            : }
<span class="lineNum">      67 </span>            : 
<span class="lineNum">      68 </span>            : // Escape
<span class="lineNum">      69 </span>            : // . Escapes the sequence starting 'in' (it must begin with a '\' or single
<span class="lineNum">      70 </span>            : // quote)
<a name="71"><span class="lineNum">      71 </span>            : //   and returns the result.</a>
<span class="lineNum">      72 </span>            : // . Throws if it's an unknown escape character.
<span class="lineNum">      73 </span><span class="lineCov">       8554 : std::string Escape(Stream&amp; in) {</span>
<span class="lineNum">      74 </span>            :   // eat slash
<span class="lineNum">      75 </span><span class="lineCov">       8554 :   char escape = in.get();</span>
<span class="lineNum">      76 </span>            : 
<span class="lineNum">      77 </span>            :   // switch on escape character
<span class="lineNum">      78 </span><span class="lineCov">       8554 :   char ch = in.get();</span>
<span class="lineNum">      79 </span>            : 
<span class="lineNum">      80 </span>            :   // first do single quote, since it's easier
<span class="lineNum">      81 </span><span class="lineCov">       8554 :   if (escape == '\'' &amp;&amp; ch == '\'')</span>
<span class="lineNum">      82 </span><span class="lineCov">        460 :     return &quot;\'&quot;;</span>
<span class="lineNum">      83 </span>            : 
<span class="lineNum">      84 </span>            :   // now do the slash (we're not gonna check if it's a slash - you better pass
<span class="lineNum">      85 </span>            :   // one!)
<span class="lineNum">      86 </span><span class="lineCov">       8094 :   switch (ch) {</span>
<span class="lineNum">      87 </span>            :     case '0':
<span class="lineNum">      88 </span><span class="lineCov">       1727 :       return std::string(1, '\x00');</span>
<span class="lineNum">      89 </span>            :     case 'a':
<span class="lineNum">      90 </span><span class="lineCov">        388 :       return &quot;\x07&quot;;</span>
<span class="lineNum">      91 </span>            :     case 'b':
<span class="lineNum">      92 </span><span class="lineCov">        310 :       return &quot;\x08&quot;;</span>
<span class="lineNum">      93 </span>            :     case 't':
<span class="lineNum">      94 </span>            :     case '\t':
<span class="lineNum">      95 </span><span class="lineCov">        417 :       return &quot;\x09&quot;;</span>
<span class="lineNum">      96 </span>            :     case 'n':
<span class="lineNum">      97 </span><span class="lineCov">        137 :       return &quot;\x0A&quot;;</span>
<span class="lineNum">      98 </span>            :     case 'v':
<span class="lineNum">      99 </span><span class="lineCov">        140 :       return &quot;\x0B&quot;;</span>
<span class="lineNum">     100 </span>            :     case 'f':
<span class="lineNum">     101 </span><span class="lineCov">        150 :       return &quot;\x0C&quot;;</span>
<span class="lineNum">     102 </span>            :     case 'r':
<span class="lineNum">     103 </span><span class="lineCov">        133 :       return &quot;\x0D&quot;;</span>
<span class="lineNum">     104 </span>            :     case 'e':
<span class="lineNum">     105 </span><span class="lineCov">         88 :       return &quot;\x1B&quot;;</span>
<span class="lineNum">     106 </span>            :     case ' ':
<span class="lineNum">     107 </span><span class="lineCov">        297 :       return &quot;\x20&quot;;</span>
<span class="lineNum">     108 </span>            :     case '\&quot;':
<span class="lineNum">     109 </span><span class="lineCov">        234 :       return &quot;\&quot;&quot;;</span>
<span class="lineNum">     110 </span>            :     case '\'':
<span class="lineNum">     111 </span><span class="lineCov">        400 :       return &quot;\'&quot;;</span>
<span class="lineNum">     112 </span>            :     case '\\':
<span class="lineNum">     113 </span><span class="lineCov">       1070 :       return &quot;\\&quot;;</span>
<span class="lineNum">     114 </span>            :     case '/':
<span class="lineNum">     115 </span><span class="lineCov">        154 :       return &quot;/&quot;;</span>
<span class="lineNum">     116 </span>            :     case 'N':
<span class="lineNum">     117 </span><span class="lineCov">        133 :       return &quot;\x85&quot;;</span>
<span class="lineNum">     118 </span>            :     case '_':
<span class="lineNum">     119 </span><span class="lineCov">        141 :       return &quot;\xA0&quot;;</span>
<span class="lineNum">     120 </span>            :     case 'L':
<span class="lineNum">     121 </span><span class="lineCov">        216 :       return &quot;\xE2\x80\xA8&quot;;  // LS (#x2028)</span>
<span class="lineNum">     122 </span>            :     case 'P':
<span class="lineNum">     123 </span><span class="lineCov">        466 :       return &quot;\xE2\x80\xA9&quot;;  // PS (#x2029)</span>
<span class="lineNum">     124 </span>            :     case 'x':
<span class="lineNum">     125 </span><span class="lineCov">        830 :       return Escape(in, 2);</span>
<span class="lineNum">     126 </span>            :     case 'u':
<span class="lineNum">     127 </span><span class="lineCov">        208 :       return Escape(in, 4);</span>
<span class="lineNum">     128 </span>            :     case 'U':
<span class="lineNum">     129 </span><span class="lineCov">        160 :       return Escape(in, 8);</span>
<span class="lineNum">     130 </span>            :   }
<span class="lineNum">     131 </span>            : 
<span class="lineNum">     132 </span><span class="lineCov">        590 :   std::stringstream msg;</span>
<span class="lineNum">     133 </span><span class="lineCov">        295 :   throw ParserException(in.mark(), std::string(ErrorMsg::INVALID_ESCAPE) + ch);</span>
<a name="134"><span class="lineNum">     134 </span>            : }</a>
<span class="lineNum">     135 </span>            : }
<span class="lineNum">     136 </span><span class="lineCov">       6108 : }</span>
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.11</a></td></tr>
  </table>
  <br>

</body>
</html>
